Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@gramio/types
Advanced tools
7.3.x types are for 7.3 Telegram Bot API
import type { APIMethods, APIMethodReturn } from "@gramio/types";
type SendMessageReturn = Awaited<ReturnType<APIMethods["sendMessage"]>>;
// ^? type SendMessageReturn = TelegramMessage
type GetMeReturn = APIMethodReturn<"getMe">;
// ^? type GetMeReturn = TelegramUser
Please see API Types References
This library is updated automatically to the latest version of the Telegram Bot API in case of changes thanks to CI CD! If the github action failed, there are no changes in the Bot API
@gramio/
)index
- exports everything in the sectionmethods
- exports APIMethods
which describes the api functionsobjects
- exports objects with the Telegram
prefix (for example Update)params
- exports params that are used in methods
with Params
postfiximport type {
APIMethods,
APIMethodParams,
TelegramAPIResponse,
} from "@gramio/types";
const TBA_BASE_URL = "https://api.telegram.org/bot";
const TOKEN = "";
const api = new Proxy({} as APIMethods, {
get:
<T extends keyof APIMethods>(_target: APIMethods, method: T) =>
async (params: APIMethodParams<T>) => {
const response = await fetch(`${TBA_BASE_URL}${TOKEN}/${method}`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(params),
});
const data = (await response.json()) as TelegramAPIResponse;
if (!data.ok) throw new Error(`Some error occurred in ${method}`);
return data.result;
},
});
api.sendMessage({
chat_id: 1,
text: "message",
});
@gramio/keyboards
import { Keyboard } from "@gramio/keyboards";
// the code from the example above
api.sendMessage({
chat_id: 1,
text: "message with keyboard",
reply_markup: new Keyboard().text("button text"),
});
Prerequire - rust
git clone https://github.com/gramiojs/types.git
git clone https://github.com/ark0f/tg-bot-api.git
cloned
foldercd tg-bot-api && cargo run --package gh-pages-generator --bin gh-pages-generator -- dev && cd ..
root
of the projectbun generate
or, if you don't use bun
, use tsx
npx tsx src/index.ts
out
folder!FAQs
Code-generated and Auto-published Telegram Bot API types
The npm package @gramio/types receives a total of 468 weekly downloads. As such, @gramio/types popularity was classified as not popular.
We found that @gramio/types demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.